﻿using commonFramwork.Log;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http.Filters;

namespace apiframworkTest.Extend
{
    /// <summary>
    /// 全局异常处理
    /// </summary>
    public class MyuExceptionFilterAttribute : ExceptionFilterAttribute
    {

        private static MyuLogger loger = new MyuLogger(typeof(MyuExceptionFilterAttribute));
        public override void OnException(HttpActionExecutedContext actionExecutedContext)
        {

        }

        public  override Task OnExceptionAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)
        {
            //  var ss = actionExecutedContext.Request.Method.ToString();
            return Task.Run(() => { loger.Error(actionExecutedContext.Exception.Message); });
        }

    }
}